from core.basehandler import BaseHandler
from core.room import Room
from core.action import Action
from core.support import set_cutscene

class Soldier(Room):
    def __init__(self, room_id):
        Room.__init__(self, room_id)    # do basic initialization for every room
        self.locked = True
        # build list of actions
        if self.locked:
            self.add_action(Dagger)
            self.add_action(Arrow)
            self.add_action(Crossbow)
    
    # return description of room.
    def get_description(self):
        return '''There is Terracotta army in the tomb, intended to protect the emperor after his death! 
        Soldier A, B, C owned different weapons. 
        Three hints were written on the wall: A got the arrow, B didn't owned the arrow, C didn't own the crossbow. 
        Only one sentence was right. The adventurer should find which weapon belongs to soldier C.
        '''    
        
    # return image of room
    def get_image(self):
        return "Terracotta_army.jpg"

class SoldierHandler(BaseHandler):
    
    # return class to use to create a new instance of this room
    def get_room_class(self):
        return Soldier

# define actions for this room
class Dagger(Action):
    def __init__(self):
        Action.__init__(self, "dagger")
        
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Dagger"
    
    # return id of room to enter when action is complete
    def do_action(self,game,room,request):
        set_cutscene("The Door is open")
        room.locked = False
        room.add_action(SoldierToCliff)
     
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "get"

class Arrow(Action):
    def __init__(self):
        Action.__init__(self, "arrow")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Arrow"
    
    def get_method(self):
        return "get"
   
    def get_destination(self):
        return 'death'

class Crossbow(Action):
    def __init__(self):
        Action.__init__(self, "crossbow")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Crossbow"
    
    def get_destination(self):
        return 'death'

    
class SoldierToCliff(Action):
    def __init__(self):
        Action.__init__(self, "soldier_to_cliff")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Enter Door"
    
    # return id of room to enter when action is complete
    def get_destination(self):
        return 'cliff'
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "get"

